// [[ OnflowGenerator File UUID: abe156380326400dbffcf96a996dedaf  ]]
package com.itdct.onflow.system.menu.controller

import com.itdct.onflow.core.type.*
import com.itdct.onflow.core.vo.KeyLabelValueChildrenVo
import com.itdct.onflow.core.vo.KeyLabelValueVo
import com.itdct.onflow.core.vo.RespPageVo
import com.itdct.onflow.core.vo.RespVo
import com.itdct.onflow.system.common.base.BaseSysController
import com.itdct.onflow.system.menu.qo.SysMenuEditQo
import com.itdct.onflow.system.menu.qo.SysMenuSearchQo
import com.itdct.onflow.system.menu.service.SysMenuService
import com.itdct.onflow.system.menu.vo.MenuRoleVo
import com.itdct.onflow.system.menu.vo.SysMenuDetailVo
import com.itdct.onflow.system.menu.vo.SysMenuListVo
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.Parameter
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.http.MediaType
import org.springframework.validation.annotation.Validated
import org.springframework.web.bind.annotation.*

/**
 * @author DCTANT
 * @date 2025-09-01 14:35:02
 * @version 1.0
 * @description 系统菜单接口控制
 */
@Tag(name = SysMenuController.moduleName)
@RestController
@RequestMapping(value = ["/sysMenu"], produces = [MediaType.APPLICATION_JSON_VALUE], method = [RequestMethod.POST])
class SysMenuController(
    val sysMenuService: SysMenuService
) : BaseSysController() {
    companion object {
        const val moduleName = "系统菜单"
    }

    @Operation(summary = moduleName + "添加")
    @PostMapping("/add.adw")
    fun add(@RequestBody @Validated(Add::class) qo: SysMenuEditQo): RespVo<Long> {
        return sysMenuService.add(qo, getContext())
    }

    @Operation(summary = moduleName + "更新")
    @PostMapping("/update.adw")
    fun update(@RequestBody @Validated(Update::class) qo: SysMenuEditQo): RespVo<Unit> {
        return sysMenuService.update(qo, getContext())
    }

    @Operation(summary = moduleName + "删除")
    @PostMapping("/delete.adw")
    fun delete(@RequestBody @Validated(Delete::class) qo: SysMenuEditQo): RespVo<Unit> {
        return sysMenuService.delete(qo, getContext())
    }

    @Operation(summary = moduleName + "详情")
    @PostMapping("/detail.adw")
    fun detail(@RequestBody @Validated(Detail::class) qo: SysMenuSearchQo): RespVo<SysMenuDetailVo> {
        return sysMenuService.detail(qo, getContext())
    }

    @Operation(summary = moduleName + "列表")
    @PostMapping("/page.adw")
    fun page(@RequestBody @Validated(Page::class) qo: SysMenuSearchQo): RespPageVo<SysMenuListVo> {
        return sysMenuService.page(qo, getContext())
    }

    @Operation(summary = moduleName + "列表")
    @PostMapping("/roleMenuList.adw")
    fun roleMenuList(@RequestBody qo: SysMenuSearchQo): RespVo<List<MenuRoleVo>> {
        return sysMenuService.roleMenuList(qo, getContext())
    }

    @Operation(summary = moduleName + "更新")
    @PostMapping("/clone.adw")
    fun clone(@RequestBody @Parameter eo: SysMenuEditQo): RespVo<Unit> {
        return sysMenuService.clone(eo, getContext())
    }

    @Operation(summary = moduleName + "菜单层级选择")
    @PostMapping("/chooseTitleCascade.adw")
    fun chooseTitleCascade(@RequestBody qo: SysMenuSearchQo): RespVo<List<KeyLabelValueChildrenVo>> {
        return sysMenuService.chooseTitleCascade(qo, getContext())
    }

    // [[ OnflowGenerator Range (- selectFunctions -) Start ]]
    @Operation(summary = moduleName + "显示菜单名称下拉选")
    @PostMapping("/selectTitleList.adw")
    fun selectTitleList(@RequestBody qo: SysMenuSearchQo): RespVo<List<KeyLabelValueVo>> {
        return sysMenuService.selectTitleList(qo, getContext())
    }

    @Operation(summary = moduleName + "前端模块名称下拉选")
    @PostMapping("/selectNameList.adw")
    fun selectNameList(@RequestBody qo: SysMenuSearchQo): RespVo<List<KeyLabelValueVo>> {
        return sysMenuService.selectNameList(qo, getContext())
    }

// [[ OnflowGenerator Range (- selectFunctions -) End ]]
}